package com.vavr.checkincms.controller;

import java.util.List;
import com.vavr.checkincms.common.domain.BaseResult;
import com.vavr.checkincms.common.domain.ResultEnum;
import com.vavr.checkincms.domain.bo.MeetingInfoBO;
import com.vavr.checkincms.domain.bo.MeetingParticipantBO;
import com.vavr.checkincms.domain.dto.MeetingConfigDTO;
import com.vavr.checkincms.domain.dto.MeetingInfoDTO;
import com.vavr.checkincms.service.MeetingInfoService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 会议基础信息Controller
 *
 * @since 2024.11
 */
@RestController
public class MeetingInfoController {
    /**
     * meetingInfoService
     */
    private final MeetingInfoService meetingInfoService;

    public MeetingInfoController(MeetingInfoService meetingInfoService) {
        this.meetingInfoService = meetingInfoService;
    }

    /**
     * 通过会议id获取会议配置信息
     *
     * @param bo {@link MeetingInfoBO}
     * @return 参会者信息
     */
    @PostMapping("/getMeetingConfig")
    public BaseResult<List<MeetingConfigDTO>> getMeetingConfig(@RequestBody MeetingInfoBO bo) {
        return BaseResult.of(ResultEnum.OK, meetingInfoService.getMeetingConfig(bo.getMeetingId()));
    }


    /**
    * 通过手机号码查询参会者信息
    *
    * @param bo {@link MeetingInfoBO}
    * @return 参会者信息
    */
    @PostMapping("/getMeetingList")
    public BaseResult<List<MeetingInfoDTO>> getMeetingList(@RequestBody MeetingInfoBO bo) {
    return BaseResult.of(ResultEnum.OK, meetingInfoService.getMeetingList(bo));
    }

    /**
     * 导出用户信息
     *
     * @param bo {@link MeetingInfoBO}
     * @return 参会者信息
     */
    @PostMapping("/getMeetingUserInfo")
    public BaseResult<String> getMeetingUserInfo(@RequestBody MeetingInfoBO bo, HttpServletResponse response,
            HttpServletRequest request) {
        meetingInfoService.getMeetingUserInfo(bo, response, request);
        return BaseResult.of(ResultEnum.OK, ResultEnum.OK.getMsg());
    }
}
